home *** CD-ROM | disk | FTP | other *** search
/ Programmer Power Tools / Programmer Power Tools.iso / progjrn / pj_5_5.arc / OUTDEMO.C < prev    next >
Text File  |  1987-08-07  |  1KB  |  45 lines

  1. /*    Source Code for "A Note on Printer Output from Turbo C Programs"
  2.                            by Bernard H. Robinson, Jr.
  3.       Page 48, Volume 5.5, Programmer's Journal
  4.       Copyright 1987, Bernard H. Robinson, Jr., All Rights Reserved
  5. */
  6. /******************************
  7. *       name: outdemo.c
  8. *    purpose: Demonstrate two ways of printer output for Turbo C
  9. * written by: Bernard H. Robinson, Jr.
  10. *       date: June 1, 1987
  11. *    version: 005
  12. *******************************/
  13.  
  14. #include "stdio.h"   /* For FILE structure; fdopen, fprintf, printf,
  15.                         and  fcloseall functions */
  16. #include "process.h" /* For exit function */
  17. #include "io.h"      /* for write function */
  18.  
  19. FILE *stdprt;   /* declare stdprt pointer to FILE structure  */
  20.  
  21. void main()
  22. {
  23.     int i;
  24.     char *s1,*s2;
  25.     s1 = "This is a test line for the write function.\n";
  26.     s2 = "This is a test line for the fprintf function.\n";
  27.  
  28.     write(4,s1,strlen(s1));                /* Level one printer output */
  29.  
  30.     /* Now lets go on to level two printer output */
  31.  
  32.     /* First point "stdprt" to the printer */
  33.  
  34.     if( (stdprt = fdopen( 4, "wt" ))  == NULL) {
  35.         printf("Unable to open printer");
  36.         i = -1;
  37.         exit(i);
  38.     }
  39.     /* Now use "stdprt" to output to printer */
  40.  
  41.     fprintf(stdprt,"%s",s2);
  42. }
  43. /************* End of program ****************/
  44.  
  45.